package org.millenaire_reborn.datagen;

import net.minecraft.data.PackOutput;
import net.neoforged.neoforge.common.data.LanguageProvider;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredItem;
import org.millenaire_reborn.MillenaireReborn;
import org.millenaire_reborn.annotations.AutoItem;
import org.millenaire_reborn.init.ModItems;

import java.lang.reflect.Field;
import java.util.stream.Collectors;

public class ModEnLanguageProvider extends LanguageProvider {

    public ModEnLanguageProvider(PackOutput output) {
        super(output, MillenaireReborn.MOD_ID, "en_us");
    }

    @Override
    protected void addTranslations() {
        add("itemGroup.millnaire", "千年村庄");
        for (Field field: ModItems.class.getFields()) {
            var anno = field.getAnnotation(AutoItem.class);
            if (anno != null) {
                try {
                    add(((DeferredItem<?>)field.get(field.getDeclaringClass())).get(), anno.en());
                } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
